<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con">
            <span>批量修改</span><div class="move_title"></div><?php include "../public/sub.php";?></div>
    </div>
    <div class="main-container">

        <div class="block-generic">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>基本信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>选择要修改的字段</label>
                        <div class="layui-input-block">
                            <select class="layui-select" name="fieldname" id="fieldname" lay-filter="fieldname">
                                <option value="">请选择</option>
                                <option value="startdt">使用开始时间</option>
                                <option value="yudt">预计结束时间</option>
                                <option value="enddt">使用结束时间</option>
                            </select>
                            <p class="error" id="fieldname_error" style="margin: 0;"></p>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-form-item layui-hide field_divss startdt_divss">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">使用开始时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="startdt" id="startdt" placeholder="请选择" clearable autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide field_divss yudt_divss">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">预计结束时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="yudt" id="yudt" placeholder="请选择" clearable autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide field_divss enddt_divss">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">使用结束时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="enddt" id="enddt" placeholder="请选择" clearable autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                </div>
            </div>
        </div>


    </div>
</form>
<script>
    var param_ids = getQueryVariable('ids');

    $("#commentForm").validate({
        rules: {
            startdt: {required: true},
            yudt: {required: true},
            enddt: {required: true},
        },
        messages:{
            startdt: {required: "请选择"},
            yudt: {required: "请选择"},
            enddt: {required: "请选择"},
        }
    });

    layui.use(['laytp','form'], function() {
        var form = layui.form;

        render_from();

        form.on('select(fieldname)', function(data){
            if(data.value == ''){
                $('#fieldname_error').show().text('请选择');
                $('#fieldname_error').parent().find('input').addClass('select_error');
            }else{
                $('#fieldname_error').hide();
                $('#fieldname_error').parent().find('input').removeClass('select_error');


                $(".field_divss").addClass('layui-hide');
                $("."+data.value+"_divss").removeClass('layui-hide');
                if(data.value == 'state'){
                    if($("#state").val() == 2 || $("#state").val() == 3){
                        $(".out_dt_divss").removeClass('layui-hide');
                    }else{
                        $(".out_dt_divss").addClass('layui-hide');
                    }
                }
            }
            render_from();
            render_date();
        });

        form.on('select(form)', function(data){
            if(data.value == ''){
                $('#form_error').show().text('请选择');
                $('#form_error').parent().find('input').addClass('select_error');
            }else{
                $('#form_error').hide();
                $('#form_error').parent().find('input').removeClass('select_error');
            }
        });

        form.on('submit(add)', function(data){
            var validRes = $("#commentForm").valid();

            if(data.field.fieldname == ''){
                $('#fieldname_error').show().text('请选择');
                $('#fieldname_error').parent().find('input').addClass('select_error');
                validRes = false;
            }else{
                $('#fieldname_error').hide();
                $('#fieldname_error').parent().find('input').removeClass('select_error');
            }

            if(!validRes){return false;}

            parent.mulreplace_data(data.field.fieldname, data.field[data.field.fieldname])
            layer_close();
            return false;
        });

    });
</script>
</body>
</html>
